// 设计用户的表模型
const mongoose = require('mongoose')
const Schema = mongoose.Schema
//设计用户的模型
const UserSchema = new Schema({
    // 用户名
    phone: {
        type: String,
        require: true,
        unique: true
    },
    // 密码
    password: {
        type: String,
        require: true,
    },
    score: {
        type: Number,
        default: 0
    },
    // Vip属性
    Vip: {
        isVip: {
            type: Boolean,
            default: false
        },
        level: {
            type: Number,
            default: 0
        }
    },
    // 头像
    headImg: {
        type: String,
        default: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fku.90sjimg.com%2Felement_origin_min_pic%2F01%2F37%2F09%2F22573c3a831082c.jpg&refer=http%3A%2F%2Fku.90sjimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1648981173&t=5329df61c7583a7a757fb1a357590fc5",
        require: true
    },
    // 用户名称
    username: {
        type: String,
        default: '观鸟爱好者'
    },
    // 身份认证
    identity: {
        isOK: {
            type: Boolean,
            default: false
        },
        idCardNum: {
            type: String,
            default: ''
        },
        realName: {
            type: String,
            default: '观鸟爱好者'
        },
    },
    // 性别
    sex: {
        type: String,
        default: ''
    },
    // 我的关注
    followers: [{
        type: Schema.Types.ObjectId,
        ref: 'User', //表关联
        require: true
    }],
    // 我的粉丝
    fans: [{
        type: Schema.Types.ObjectId,
        ref: 'User', //表关联
        require: true
    }],
    // 我的消息
    msg: {
        type: Array,
        default: []
    },
    // 我的点赞的笔记列表
    likeNotes: [{
        type: Schema.Types.ObjectId,
        ref: 'NoteSchema', //表关联
        require: true
    }
    ],
    userDescriptions: {
        type: String,
        default: '默认个人描述'
    }
})
//通过 mongoose.model 往 mongoodb数据库里面映射出一张User表
module.exports = mongoose.model('User', UserSchema)